var mygrid;
$(function() {
	mygrid = $("#list").jqGrid({
		url : "security/notify/security-notify!secueventdata",
		datatype : "json",
		mtype : 'GET',
		colNames : [ '角色名称', '事件类型' , '发生时间','管理' ],
		colModel : [ {
			name : 'role',
			index : 'role',
			width : 200
		},{
			name:"event",
			index:"event"
			
		},{
			name : 'modifyDate',
			index : 'modifyDate',
			width : 200
			
		},{
			name:'id',
			index:'id',
			formatter:mgrFormatter
		} ],
		pager : '#pager',
		rowNum : 10,
		rowList : [ 10, 20, 30 ],
		sortname : 'modifyDate',
		sortorder : 'desc',
		viewrecords : true,
		caption : '系统权限变更通知',
		width : '600',
		height : '300',
		jsonReader : {
			repeatitems : false,
			id : "0"
		}
	});

	$("#toggleType").bind("click",function(){
		mygrid.jqGrid("setGridParam",{"page":1,"rows":10,"postData":{"searchMap['_search']":"true","searchMap['done']":$("#notifyType").val()}}); 
		mygrid.trigger("reloadGrid");
	});
});
function mgrFormatter(v,opt,row){
	var done = row['done'];
	if(done==true)return '已处理';
	var txt = done=='true'?'已处理':'未处理';
	var btn = $("<button  onclick=\"doneEvent('"+v+"');\">"+txt+"</button>")
	return $("<p></p>").append(btn).html();
}

function doneEvent(id){
	var url = "security/notify/security-notify!donesecuevent?bean.id="+id;
	   doSubmit(url,"",function(){
		   mygrid.trigger("reloadGrid");
	   });
}